const BaseMapper = require("../../library/base-mapper");
const Model = require("../model/wechat");
const {Op} = require("sequelize");

module.exports = class WechatMapper extends BaseMapper{
    constructor() {
        super();
        this.model = Model
    }

    handleSearch(params, options) {
        if(params['nickname']){
            options.where['nickname'] = {
                [Op.substring]: params['nickname']
            }
        }
        if(params['owner']){
            options.where['owner'] = {
                [Op.substring]: params['owner']
            }
        }
        if(params['type']){
            options.where['type'] = {
                [Op.eq]: params['type']
            }
        }

        super.handleSearch(params, options)
    }
}